package ipad.asia.service.enterprise.impl;

import ipad.asia.dao.ProductDao;
import ipad.asia.entity.Product;
import ipad.asia.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
@Transactional
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductDao productDao;
    @Override
    public Product findById(int id) {
        return productDao.findById(id);
    }

    @Override
    public List<Product> findByNameLike(String name) {
        return productDao.findByNameLike(name);
    }

    @Override
    public List<Product> findByKind(String kind) {
        return productDao.findByKind(kind);
    }

    @Override
    public List<Product> findByPriceBetween(int down, int up) {
        return productDao.findByPriceBetween(down,up);
    }

    @Override
    public List<Product> findByHaveDiscount(int flag) {
        return productDao.findByHaveDiscount(flag);
    }

    @Override
    public List<Product> findByUndercarriage(int flag) {
        return productDao.findByUndercarriage(flag);
    }

    @Override
    public List<Product> findByHaveSell(int flag) {
        return productDao.findByHaveSell(flag);
    }

    @Override
    public void deleteById(int id) {
        productDao.deleteById(id);
    }

    @Override
    public void save(Product product) {
        productDao.saveAndFlush(product);
    }

    @Override
    public List<Product> findAll() {
       return productDao.findAll();
    }
}
